<?php
class Payment_model extends Model {

    function Payment_model()
    {
        // Call the Model constructor
        parent::Model();
    }
    
	function insert_payment($data)
	{
		$this->db->insert($this->db->dbprefix.'payments', $data);
		return $this->db->insert_id();
	}
	
	function update_payment($payment_id, $data_payment)
	{
		$this->db->where('payment_id', $payment_id);
		$this->db->update($this->db->dbprefix.'payments', $data_payment);
	}

	function check_auth($booking_id, $string_auth)
	{
		$this->db->select('COUNT(booking_id) as cpt');
		$query = $this->db->where('booking_id',$booking_id);
		$query = $this->db->where('payment_auth',$string_auth);
		$query = $this->db->get($this->db->dbprefix . 'payments');	
		$total = $query->row();
		if ($total->cpt > 0)
			return TRUE;
		else 
			return FALSE;
	}	
	
	function get_payment_booking($booking_id)
	{
		$this->db->select($this->db->dbprefix . 'payments.*');
		$query = $this->db->where($this->db->dbprefix . 'payments.booking_id = '.$booking_id);
		$query = $this->db->get($this->db->dbprefix . 'payments');
		$payments = $query->result_array();
		return $payments;	
	}
}
?>